/**
 * @author 徐楠
 * @date 2022/4/15 22:44
 * @version 1.0
 */

package com.xunan.likou;

public class DetectCapitalLetters {
    public static void main(String[] args) {
        //String word = "FlaG";
        String word = "Leetcode";
        System.out.println(word.toUpperCase());
        System.out.println(word.toLowerCase());
        boolean b = detectCapitalUse(word);
        System.out.println(b);
    }

    public static boolean detectCapitalUse(String word) {
        //全大写
        if (word.toUpperCase().equals(word)) return true;
        //全小写
        if (word.toLowerCase().equals(word)) return true;
        int length = word.length();
        int index = 1;
        if (Character.isUpperCase(word.charAt(0))) {
            while (index < length) {
                System.out.println(word.charAt(index));
                if (Character.isUpperCase(word.charAt(index))) {
                    break;
                }
                index++;
            }
        }
        System.out.println(index);
        return index == length;
    }
}
